
//省
function province(){
	var p_name = $("#p_name").val();
	var url = "/common/province";
	$.getJSON(url, function(json){
		var html = '';
		html += '<option value="">请选择</option>';
		for(var i=0;i<json.length;i++){
			html += '<option value="'+json[i].province+'"';
			if(json[i].province == p_name){
				html += 'selected="selected"';
			}
			html += '>'+json[i].province+'</option>'
		}
		$("#province").html(html);
	});
}

function changeCity(){
	var province = $("#province").val();
	var p_name = $("#p_name").val();
	var c_name = $("#c_name").val();
	if(province == ''){ province = p_name;	}
	var url = "/common/city/"+province;
	$.getJSON(url, function(json){
		var html = '';
		html += '<option value="">请选择</option>';
		for(var i=0;i<json.length;i++){
			html += '<option value="'+json[i].city+'"';
			if(json[i].city == c_name){
				html += 'selected="selected"';
			}
			html += '>'+json[i].city+'</option>'
		}
		$("#city").html(html);
	});
}

function changeArea(){
	var city = $("#city").val();
	var a_name = $("#a_name").val();
	var c_name = $("#c_name").val();
	if(city == ''){ city = c_name; }
	var url = "/common/area/"+city;
	$.getJSON(url, function(json){
		var html = '';
		html += '<option value="">请选择</option>';
		for(var i=0;i<json.length;i++){
			html += '<option value="'+json[i].area+'"';
			if(json[i].area == a_name){
				html += 'selected="selected"';
			}
			html += '>'+json[i].area+'</option>'
		}
		$("#county").html(html);
	});
}

function post(url,params,callback){
	$.post(url,params, function(json){
		if(json.code == 401){
			document.location = "/lottery/login.html";
		}else{
			callback(json);
		}
	});
}
function get(url,params,callback){
	$.get(url,params, function(json){
		if(json.code == 401){
			document.location = "/lottery/login.html";
		}else{
			callback(json);
		}
	});
}



